package com.agency.controller;

import com.allo2o.common.VO.AgencyVO;
import com.allo2o.common.convertor.AgencyConvertor;
import com.allo2o.common.domain.AgencyDO;
import com.allo2o.common.lepayEnum.PayTypeEnum;
import com.allo2o.common.mapper.AgencyDOMapper;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Created by Lu.Bing on 16-7-6.
 *
 * @author Lu.Bing
 */
@Controller
public class MainFrameVMLoadController {

    private static final Logger LOGGER = LoggerFactory.getLogger(AgentController.class);

    @Resource
    private AgencyDOMapper agencyDOMapper;

    @RequestMapping(value = "loadVM.htm")
    public String loadVM(@RequestParam("vmname") String vmname, ModelMap modelMap) {
//        if (StringUtils.equals(vmname, "addAgent")) {
//            try {
//                List<AgencyDO> agencyDOs = agencyDOMapper.selectProvAgents();
//                List<AgencyVO> provAgents = agencyDOs.stream().map(AgencyConvertor::DO2VOConvert).collect(Collectors.toList());
//                modelMap.addAttribute("provAgents", provAgents);
//            } catch (Exception e) {
//                LOGGER.error("查询省级代理商异常", e);
//            }
//        } else if(StringUtils.equals("setPayRate", vmname)) {
//            HashMap<String, String> map = new HashMap<>();
//            map.put(PayTypeEnum.ALIPAY_QR_CODE.getCode(), PayTypeEnum.ALIPAY_QR_CODE.getDesc());
//            map.put(PayTypeEnum.ALIPAY_SCAN.getCode(), PayTypeEnum.ALIPAY_SCAN.getDesc());
//            map.put(PayTypeEnum.WECHAT_QR_CODE.getCode(), PayTypeEnum.WECHAT_QR_CODE.getDesc());
//            map.put(PayTypeEnum.WECHAT_SUBSCRIPTION.getCode(), PayTypeEnum.WECHAT_SUBSCRIPTION.getDesc());
//            modelMap.addAttribute("map", map);
//        }
        return "mainframe/" + vmname;
    }
}
